from math import *

def sinc(x):
    if x == 0:
        return 1
    else:
        return sin(x) / x
    
e = exp(1)

__IO_INDEX__ = 1
__LAST_OUTPUT__ = None

while True:
    print('\n')
    string = input(f'In [{__IO_INDEX__}]: ')

    if '%%' in string:
        print("Error: '%%' is not allowed.")
        continue

    if '%' in string:
        if __LAST_OUTPUT__ is not None:
            string = string.replace('%', str(__LAST_OUTPUT__))
        else:
            print('No previous output')
            continue

    if '__IO_INDEX__' in string:
        print("name '__IO_INDEX__' is reserved")
    else:
        try:
            __LAST_OUTPUT__ = eval(string)
            print(f'Out[{__IO_INDEX__}]: {__LAST_OUTPUT__}')
        except (NameError, SyntaxError):
            try:
                exec(string)
            except Exception as e:
                print(e)
        except Exception as e:
            print(e)
        __IO_INDEX__ += 1
